package com.day07;

/**
 * This关键字的使用
 */
public class ThisTest {

    public static void main(String[] args) {
        Demo demo = new Demo();
        demo.setAge(1);
        System.out.println(demo.getAge());
    }

}


class Demo {

    public Demo() {
        //用this调用方法
        this.eat();

    }

    public Demo(int age) {
        //用this调用构造方法。
        this();
    }


    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void eat() {
        System.out.println("正在吃饭");
    }

}
